import java.util.LinkedList;
import java.util.Queue;

/**
 * Created with Intellij JDEA
 * Description:
 * User:
 * Date:2022-05-06
 * Time:19:48
 */
public class 最近的请求次数 {
    class RecentCounter {
        private Queue<Integer> queue;
        public RecentCounter() {
            queue = new LinkedList<>();
        }

        public int ping(int t) {
            queue.offer(t);
            int min = t - 3000;
            while (queue.peek() < min) {
                queue.poll();
            }
            int ret = queue.size();
            return ret;
        }
    }
}
